#!/bin/bash
#information
#author: gr.cn 
#email: 920098699@qq.com
#date: Tue May 28 16:43:06 CST 2013
#function:list the use and the rest of mem(%)
DATE=`date +%Y/%m/%d_%H:%M:%S`
DIR='/home/gr/tmp/log/grfree.log'
if [ ! -f $DIR ];
then
	touch $DIR
fi
#把3定向到1,1定向到文件，最后1再定向到3,恢复原来
exec 3>&1
exec 1>>$DIR
echo $DATE
exec 1>&3
free | sed -n '2p' | gawk '
{
	print "memory used:"$3/$2*100"%"
	print "memory free:"$4/$2*100"%"
}' | tee -a $DIR #-a,追加到文件后面
exit 0
